import { TextareaAutosize } from '@mui/material';
import { useEffect, useState } from 'react';

export default (props: any) => {
  const [content, setContent] = useState('');
  useEffect(() => {
    setContent(props.item.content);
  }, []);

  const handleChange = (data) => {
    setContent(data);
    props.onChange(data);
  };

  return (
    <TextareaAutosize
      style={{ width: '100%', resize: 'vertical' }}
      value={content}
      onChange={(e) => handleChange(e.target.value)}
      placeholder='请输入JSON命令'
      maxRows={20}
      minRows={10}
    />
  );
};
